package com.muyu.product.domain;

import java.util.function.Supplier;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.product.domain.model.AttrValueModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;

/**
 * 商品属性对象 as_product_attribute_info
 *
 * @author DongZeLiang
 * @date 2024-02-27
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("as_product_attribute_info")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "AsProductAttributeInfo", description = "商品属性")
public class AsProductAttributeInfo extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /** 属性编号 */
    @TableId(value = "id",type = IdType.AUTO)
    @ApiModelProperty(name = "属性编号", value = "属性编号")
    private Long id;

    /** 商品 */
    @Excel(name = "商品")
    @ApiModelProperty(name = "商品", value = "商品", required = true)
    private Long productId;

    /** 属性 */
    @Excel(name = "属性")
    @ApiModelProperty(name = "属性", value = "属性", required = true)
    private Long attributeId;

    /** 属性值 */
    @Excel(name = "属性值")
    @ApiModelProperty(name = "属性值", value = "属性值", required = true)
    private String value;
//    谁构建出谁,,
    public static AsProductAttributeInfo attrValueModelBuild(AttrValueModel attrValueModel, Supplier<Long> projectId){
        return AsProductAttributeInfo.builder()
                .productId(projectId.get())
                .attributeId(attrValueModel.getId())
                .value(attrValueModel.getValue())
                .build();
    }

}
